package com.zxh.blog.web.security.entity;

import lombok.ToString;
import org.springframework.security.core.GrantedAuthority;

import java.util.Date;
import java.io.Serializable;
import java.util.List;

/**
 * 角色(SysRole)实体类
 *
 * @author zxh
 * @since 2019-02-25 20:05:45
 */
@ToString
public class SysRole implements Serializable, GrantedAuthority {
    private static final long serialVersionUID = -51577363252994707L;
    
    private String roleId;
    //角色名称
    private String roleName;
    //备注
    private String remark;
    //创建者ID
    private Long createUserId;
    //创建时间
    private Date createTime;

    private List<SysMenu> sysMenuList;


    public String getRoleId() {
        return roleId;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Long getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(Long createUserId) {
        this.createUserId = createUserId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public List<SysMenu> getSysMenuList() {
        return sysMenuList;
    }

    public void setSysMenuList(List<SysMenu> sysMenuList) {
        this.sysMenuList = sysMenuList;
    }

    @Override
    public String getAuthority() {
        StringBuffer str=new StringBuffer();
        for (int i = 0; i < this.sysMenuList.size(); i++) {
            str.append(sysMenuList.get(i).getUrl()+"-"+sysMenuList.get(i).getPerms()+";");
        }
        return str.toString();
    }
}